{% extends "SisGGFinalBundle:Usuario:user.html.twig" %}
{% block title %}Nuevo Proveedor{% endblock %}
{% block name %}Kito's Local{% endblock%}
{% block descripcion %}Lorem ipsum ad his scripta blandit partiendo, eum fastidii accumsan euripidis in, eum liber hendrerit an. Qui ut wisi vocibus suscipiantur, quo dicit ridens inciderint id. Quo mundi lobortis reformidans eu, legimus senserit definiebas an eos. Eu sit tincidunt incorrupte definitionem, vis mutat affert percipit cu, eirmod consectetuer signiferumque eu per. In usu latine equidem dolores. Quo no falli viris intellegam, ut fugit veritus placerat per.{% endblock%}
{% block content %}
  <form action="{{ path('altaProvincia') }}" method="post">
        <legend>Nuevo Proveedor</legend>
        {{ form_errors(form) }}
        <div class="tabbable"> <!-- Only required for left/right tabs -->
            <ul class="nav nav-tabs">
                <li class="active"><a href="#tab1" data-toggle="tab">Proveedor</a></li>
                <li><a href="#tab2" data-toggle="tab">Direccion</a></li>
                <li><a href="#tab3" data-toggle="tab">Telefonos</a></li>
            </ul>
            <div class="tab-content">
                <div class="tab-pane active" id="tab1">
                    <legend>Razon Social</legend>
                    {{ form_row(form.razonSocial) }}
                    <legend>CUIT</legend>
                    {{ form_row(form.cuit.tipoglobal) }}
                    {{ form_row(form.cuit.numero) }}    
                    {{ form_row(form.cuit.verificador) }}
                    <legend>Otros datos</legend>
                    {{ form_row(form.email) }}
                    {{ form_row(form.nroBco) }}
                </div>
                <div class="tab-pane" id="tab2">
                    <label for="provincias">Provincia</label>
                    <select id="provincias" name="provincias" class="provincias" onClick="cambio();">
                    {% for provincia in provincias%}
                        <option id="{{provincia.id}}" name="{{provincia.id}}" value="{{provincia}}">
                            {{provincia}} 
                        </option>
                        
                    {% endfor %}    
                    </select>
                    <a href="#myModal" role="button" class="btn" data-toggle="modal">...</a>
                    <div id="reemplazar" name="reemplazar">
                        {{ form_row(form.direccion.ciudad) }}
                    </div>
                    {{ form_row(form.direccion.calle) }}
                    {{ form_row(form.direccion.numero) }}
                    {{ form_row(form.direccion.manzana) }}
                    {{ form_row(form.direccion.edificio) }}
                    {{ form_row(form.direccion.escalera) }}
                    {{ form_row(form.direccion.piso) }}
                    {{ form_row(form.direccion.departamento) }}
                </div>
                
                <div class="tab-pane" id="tab3">
                    <div class="span6">
                        <legend>Telefono Fijo</legend>
                            {{ form_row(form.tel1.nacional) }}
                            {{ form_row(form.tel1.caracteristica) }}
                            {{ form_row(form.tel1.numero) }}
                    </div>        
                    <div class="span6">
                        <legend>Telefono Celular</legend>
                            {{ form_row(form.tel2.nacional) }}
                            {{ form_row(form.tel2.caracteristica) }}
                            {{ form_row(form.tel2.numero) }}
                            {{ form_rest(form) }}
                   </div>        
                </div>
            </div>
        </div>
        <div class="form-actions span12">
            <button type="submit" class="btn btn-primary">Guardar Cambios</button>
            <a href="" type="button" class="btn">Cancelar</a>
        </div>
        </div>
  </form>
                <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h3 id="myModalLabel">Modal header</h3>
                    </div>
                    <div class="modal-body">
                    <form action="{{ path('altaCiudad') }}" method="post">
                        <legend>Nuevo Ciudad</legend>
                         {{ form_row(formCiudad.nombre) }}
                        {{ form_row(formCiudad.codigoPostal) }}
                        {{ form_row(formCiudad.provincia) }} <a href="#prov" role="button" class="btn" data-toggle="modal">...</a>                
                    </form>
                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-primary">Guardar Cambios</button>
                        <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
                        <a href="#myModal2" role="button" class="btn" data-toggle="modal">...</a>
                    </div>
                </div> 
        <div id="prov" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h3 id="myModalLabel">Modal header</h3>
            </div>
            <div class="modal-body">
                <form name="2" action="{{ path('altaProvincia') }}" method="post">
                <legend>Nueva Provincia</legend>
                 {{ form_widget(formProv) }}
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">Guardar</button>
                    <button class="btn" data-dismiss="modal" aria-hidden="true">Cerrar</button>
                </div>
                </form>
            </div>     
        </div> 
{% endblock %}
{% block javascripts %}
    {{parent()}}
    <script type="text/javascript">
        $(document).ready(function(){
            $('.provincias').change(function() {
                var posicion=document.getElementById('provincias').options.selectedIndex; //posicion
                $('#reemplazar').load("{{ path('ciudadesprovincia')}}",{'id':document.getElementById('provincias').options[posicion].id});
            });
            
        });
    </script>
{% endblock%}
